<html>
<head><meta charset="utf-8"><title>Syntax Trees rewrite · t-compiler/rust-analyzer · Zulip Chat Archive</title></head>
<h2>Stream: <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/index.html">t-compiler/rust-analyzer</a></h2>
<h3>Topic: <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Syntax.20Trees.20rewrite.html">Syntax Trees rewrite</a></h3>

<hr>

<base href="https://rust-lang.zulipchat.com">

<head><link href="https://rust-lang.github.io/zulip_archive/style.css" rel="stylesheet"></head>

<a name="161955511"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Syntax%20Trees%20rewrite/near/161955511" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> matklad <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Syntax.20Trees.20rewrite.html#161955511">(Mar 28 2019 at 14:07)</a>:</h4>
<p>I am experimenting with yet another rewrite of syntax trees :D</p>
<p><a href="https://github.com/rust-analyzer/rowan/pull/12" target="_blank" title="https://github.com/rust-analyzer/rowan/pull/12">https://github.com/rust-analyzer/rowan/pull/12</a></p>
<p>In the current implementation, we use the same node type for both leaves and interior nodes. This results both in awkward API (they really want to be an enum), and probably excessive memory usage (we heap-allocate every token, and there are more tokens than interior nodes)</p>



<a name="162119113"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Syntax%20Trees%20rewrite/near/162119113" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> matklad <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Syntax.20Trees.20rewrite.html#162119113">(Mar 30 2019 at 12:19)</a>:</h4>
<p>did a preliminary integration with rust-analyzer. This representation is indeed faster and more memory efficient</p>



<a name="162121587"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Syntax%20Trees%20rewrite/near/162121587" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jeremy Kolb <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Syntax.20Trees.20rewrite.html#162121587">(Mar 30 2019 at 13:36)</a>:</h4>
<p>Awesome!</p>



<a name="162161451"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Syntax%20Trees%20rewrite/near/162161451" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> matklad <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Syntax.20Trees.20rewrite.html#162161451">(Mar 31 2019 at 07:16)</a>:</h4>
<p>Got it to the point where full analysis works:</p>
<div class="codehilite"><pre><span></span>λ time ./old analysis-stats
Database loaded, 20 roots, 239.711724ms
Crates in this dir: 25
Total modules found: 265
Total declarations: 4437
Total functions: 2830
Total expressions: 53627
Expressions of unknown type: 9277 (17%)
Expressions of partially unknown type: 2867 (5%)
Analysis: 3.406900102s
real 4.20
user 3.77
sys  0.47
rss  1908544

10:13:09|~/projects/rust-analyzer|master⚡*?
λ time ./new analysis-stats
Database loaded, 20 roots, 272.906595ms
Crates in this dir: 25
Total modules found: 265
Total declarations: 4437
Total functions: 2830
Total expressions: 53627
Expressions of unknown type: 9277 (17%)
Expressions of partially unknown type: 2867 (5%)
Analysis: 2.66215654s
real 3.33
user 3.03
sys  0.34
rss  1300864
</pre></div>


<p>Time went down from <code>3.4s</code> to <code>2.6s</code>,  peak memory usage from <code>1.9G</code> to <code>1.3G</code></p>



<a name="162161511"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Syntax%20Trees%20rewrite/near/162161511" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> matklad <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Syntax.20Trees.20rewrite.html#162161511">(Mar 31 2019 at 07:18)</a>:</h4>
<p>diff is pretty annoying though :(</p>
<p><a href="https://github.com/rust-analyzer/rust-analyzer/pull/1078/files" target="_blank" title="https://github.com/rust-analyzer/rust-analyzer/pull/1078/files">https://github.com/rust-analyzer/rust-analyzer/pull/1078/files</a></p>



<a name="162170075"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Syntax%20Trees%20rewrite/near/162170075" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> matklad <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Syntax.20Trees.20rewrite.html#162170075">(Mar 31 2019 at 11:25)</a>:</h4>
<p>rowan side of work is ready for review</p>



<a name="162430350"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Syntax%20Trees%20rewrite/near/162430350" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jeremy Kolb <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Syntax.20Trees.20rewrite.html#162430350">(Apr 03 2019 at 13:43)</a>:</h4>
<p>I just did a pull and the rewrite provides a noticeable improvement</p>



<a name="162436752"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Syntax%20Trees%20rewrite/near/162436752" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> matklad <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Syntax.20Trees.20rewrite.html#162436752">(Apr 03 2019 at 15:05)</a>:</h4>
<p>Good!</p>



<hr><p>Last updated: Aug 07 2021 at 22:04 UTC</p>
</html>